import Vue from 'vue'
import VueRouter from 'vue-router'
import state from '@/vuex/state'
import iView from 'iview';
import {routers, otherRouter, appRouter} from './router';

Vue.use(VueRouter)


// 路由配置
const RouterConfig = {
    // mode: 'history',
    routes: routers
};

const routes = new VueRouter(RouterConfig);



routes.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    //不是登录页面进行判用户是否存在
    //if(to.name !=='login' && !state.userInfo){
     //   next({name:"login"});
    //}else{
        next();
    //} 
})

routes.afterEach(transition => {
    iView.LoadingBar.finish()
    window.scrollTo(0, 0)
});


export default routes;